version 8.2
#delimit;
set more off;
set memory 10m;
set matsize 100;
log using boehmke2005prq-simulate.log, replace;

/*	************************************************************	*/
/* 	Author:		Frederick J. Boehmke				*/
/*	Date:		June 30, 2005					*/
/*      File:		boehmke2005prq-simulate.do			*/
/*	Purpose:	Run first differences and generate expected	*/
/*			values using CLARIFY for negative binomial 	*/
/*			model of statewide initiatives in 		*/
/*			boehmke2005prq.pdf. 		*/
/*      Input File:	boehmke2005prq.dta				*/
/*      Output File:	boehmke2005prq-simulate.log			*/
/*      Requires:	CLARIFY add-on for Stata			*/
/*	************************************************************	*/

use boehmke2005prq;

estsimp nbreg ballot statinit consinit statcons sigs unlimit circdays singlesu distribu  primaryo 
	repgov repleg ideology econ citizen  legprof time minherf deficit, noconstant cluster(state);

setx  	(statinit consinit statcons unlimit singlesu distribu primaryo repgov repleg) p50
	(deficit ideology econ citizen minherf legprof time sigs circdays) mean 
	(consinit statcons) 0; 


foreach var of varlist statinit consinit statcons unlimit singlesu distribu primaryo repgov repleg {; 

	simqi, fd(ev) level(95) changex(`var' 0 1);
  };


foreach var of varlist deficit ideology econ citizen minherf legprof time sigs circdays {;	

	simqi, fd(ev) level(95) changex(`var' p15 p85); 
  };

simqi, fd(ev) level(95) changex(sigs 5 8); 

setx citizen p50 econ p50;

  simqi, fd(ev) level(95) changex(econ p50 p60); 
  simqi, fd(ev) level(95) changex(citizen p50 p60); 
  simqi, fd(ev) level(95) changex(econ p50 p60 citizen p50 p60); 

setx citizen 4.93 econ 8.55;	/* CA */

  simqi, fd(ev) level(95) changex(econ 8.55 9.55); 
  simqi, fd(ev) level(95) changex(citizen 4.93 5.93); 
  simqi, fd(ev) level(95) changex(econ 8.55 9.55 citizen 4.93 5.93); 

setx citizen 4.93 econ 8.55;	/* CA */
  simqi, ev level(95); 
setx citizen 1.54 econ 4.39;	/* AZ */
  simqi, ev level(95); 
setx citizen 2.27 econ 4.09;	/* OR */
  simqi, ev level(95); 
setx citizen 2.08 econ 5.59;	/* WA */
  simqi, ev level(95); 
setx citizen 0.82 econ 2.19;	/* ME */
  simqi, ev level(95); 
setx citizen 1.17 econ 2.08;	/* SD */
  simqi, ev level(95); 


log close;
clear;
exit;